package core;

/**
 * An Attribute with an integer value.
 */
public class NumericAttribute extends Attribute<NumericAttribute.IntegerValue>
{
	public NumericAttribute() {
		this(null);
	}

	public NumericAttribute(String name) {
		this(name, null);
	}

	/**
	 * Create an instance of a NumericAttribute.
	 * @param name A descriptive name for the Attribute.
	 * @param value An integer value for the Attribute.
	 */
	public NumericAttribute(String name, Integer value) {
		super(name, value == null ? null : new IntegerValue(value));
	}

	public IntegerValue parseString(String stringValue) {
		return new IntegerValue(Integer.parseInt(stringValue));
	}

	public static class IntegerValue {
		public IntegerValue() {this(null);}
		public IntegerValue(Integer value) {setValue(value);}
		public Integer getValue() {return value;}
		public void setValue(Integer value) {this.value = value;}
		public String toString() {return value == null ? null : value.toString();}
		private Integer value;
	}
}